angular.module("app").directive('appPositionClass',[function () {
    return{
        restrict:'A',
        replace:true,
        scope:{
           com:'='
        },
        templateUrl:'view/template/positionClass.html',
        link:function ($scope) {
            $scope.showPositionList = function (idx) {
                $scope.positionList = $scope.com.positionClass[idx].positionList;
                $scope.isActive = idx;
            }
            $scope.$watch('com',function (newVal) {//监听com的变化,如果不监听的话，很可能出现还在ajax请求的时候,就已经加载link函数,导致positionClass报错
                if(newVal)$scope.showPositionList(0);
            });

        }
    };
}]);